package work.soho.proxy;

import lombok.Data;

import java.io.File;

@Data
public class PartsConfigure {
    public String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    private String accessKeyId = "";

    private String accessSecret = "";

    /**
     * 是否只预检此次请求。true：发送检查请求，不会创建实例，也不会产生费用；false：发送正常请求，通过检查后直接创建实例，并直接产生费用
     */
    private static final boolean dryRun = false;
    /**
     * 实例所属的地域ID
     */
    private String regionId = "cn-hongkong";
    /**
     * 实例的资源规格
     */
    private String instanceType = "ecs.t5-lc2m1.nano";
    /**
     * 实例的计费方式
     */
    private String instanceChargeType = "PostPaid";
    /**
     * 镜像ID
     */
    private String imageId = "centos_8_2_x64_20G_alibase_20201120.vhd";
    /**https://www.baidu.com/link?url=R9vOip66Xdl9KDo9Pr7YU0jrIsIN9N7sm0LZdccJ0xOK-YvhPcM6VSmVh5Zunnv2DMewdpJOe-mredk_EAnHBK&wd=&eqid=b918e6860008c87b000000066382e55f
     * 指定新创建实例所属于的安全组ID
     */
    private String securityGroupId = "sg-j6c1cxjla4ij27l68fpy";
    /**
     * 购买资源的时长
     */
    private Integer period = 1;
    /**
     * 购买资源的时长单位
     */
    private String periodUnit = "Hourly";
    /**
     * 实例所属的可用区编号
     */
    private String zoneId = "random";
    /**
     * 网络计费类型
     */
    private String internetChargeType = "PayByTraffic";
    /**
     * 虚拟交换机ID
     */
    private String vSwitchId = "vsw-j6co80i0f2ghyzfj20ii2";
    /**
     * 实例名称
     */
    private String instanceName = "proxy-socket5-20210227";
    /**
     * 指定创建ECS实例的数量
     */
    private Integer amount = 1;
    /**
     * 公网出带宽最大值
     */
    private Integer internetMaxBandwidthOut = 100;
    /**
     * 是否为I/O优化实例
     */
    private String ioOptimized = "optimized";
    /**
     * 密钥对名称
     * TODO 从配置文件读取
     */
//    private String keyPairName = "proxySocket5KeyPairName";
    private String keyPairName = "home-ubuntu";

    /**https://github.com/FelisCatus/SwitchyOmega
     * 自动检查时间
     */
    private Integer autoCheckTs = 20;

    /**
     * ddns基本域名
     */
    private String baseDomain = "";

    /**
     * 专有网络ID
     */
    private String vpcId = null;

    /**
     * 后付费实例的抢占策略
     */
    private String spotStrategy = "SpotAsPriceGo";
    /**
     * 是否开启安全加固
     */
    private String securityEnhancementStrategy = "Active";
    /**
     * 系统盘大小
     */
    private String systemDiskSize = "40";
    /**
     * 系统盘的磁盘种类
     */
    private String systemDiskCategory = "cloud_efficiency";
    /**
     * 本地公钥名
     */
    private String localPublicKeyName = "id_rsa";

    private boolean useSocket5 = false;
    private boolean useDdns = false;
    private String localPublicKeyFile = System.getProperty("user.home") + File.separator + ".ssh"+File.separator+"id_rsa.pub";
    private String localPrivateKeyFile = System.getProperty("user.home") + File.separator + ".ssh"+File.separator+"id_rsa";

    /**
     * 代理端口
     */
    private String proxyPort = "7070";

    public String getProxyPort() {
        return proxyPort;
    }

    public void setProxyPort(String proxyPort) {
        this.proxyPort = proxyPort;
    }

    /**
     * 设置本地公钥路径
     *
     * @return
     */
    public String getLocalPublicKeyFile() {
        if(localPublicKeyFile == null) {
            setLocalPublicKeyFile(System.getProperty("user.home") + File.separator + ".ssh"+File.separator+"id_rsa.pub");
        }
        return localPublicKeyFile;
    }

    public boolean getUseDdns() {
        return useDdns;
    }

    public void setUseDdns(boolean useDdns) {
        this.useDdns = useDdns;
    }

    public boolean getUseSocket5() {
        return useSocket5;
    }

    public void setUseSocket5(boolean useSocket5) {
        this.useSocket5 = useSocket5;
    }

    public String getLocalPrivateKeyFile() {
        if(localPrivateKeyFile == null) {
            localPrivateKeyFile = System.getProperty("user.home") + File.separator + ".ssh"+File.separator+"id_rsa";
        }
        return localPrivateKeyFile;
    }
}
